﻿using Alipay.AopSdk.AspnetCore;
using FwProject.WXMiddleware;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.Extensions.DependencyInjection
{
    public static class PayConfigureExtensions
    {
        public static IServiceCollection AddPay(this IServiceCollection services, IConfigurationRoot _configurationRoot)
        {
            var alipayOptions = _configurationRoot.GetSection("Alipay").Get<AlipayOptions>();
            //检查RSA私钥
            AlipayConfigChecker.Check(alipayOptions.SignType, alipayOptions.PrivateKey);
            services.AddAlipay(options => options.SetOption(alipayOptions));
            var wxOptions = _configurationRoot.GetSection("WeiXin").Get<WxChartOptions>();
            services.AddWxChart(options => options.SetOption(wxOptions));

            return services;
        }
    }
}
